#pragma once

#include "qwindow.h"



namespace micro
{


namespace gui
{



#define SPS_VERTICAL	0
#define SPS_HORIZONTAL	1


class QSplitter: public QWindow
{

    ///	tooltip
    QString		GetToolTip();
    QToolTip	m_toolTip;
    
    
protected:
    bool		m_bIsPressed;
    QPoint		m_ptDown;
    
    bool        m_fixed;
    
    
    UINT		m_style;
    QCOLOR		m_bkColor;
    
    
    
    
    int			m_sPos;
    int 		m_percent;
    
    
    int			m_nMinFirst, m_nMinSecond;
    
    
    QWindow*    m_first;
    QWindow*    m_second;
    
    QRect		m_rcSplitter; //all window
public:
    QSplitter( void );
    ~QSplitter( void );
    virtual bool Create(  QWindow* pParent, int id, UINT style );
    
    void		SetMinSizes( int first, int second );
    void		SetPercent( int p )
    {
        m_percent = p;
    }
    
    void        SetPanels( QWindow* first, QWindow* second );
    void		SetFixed()
    {
        m_fixed = true;
    };
    
    
    void		SetSplitterStyle();
    void		SetBkColor( QCOLOR c );
    UINT		GetSplitterStyle();
    UINT		GetSplitterPos();
    bool		SetSplitterPos( int xyPos = -1, bool bUpdate = true );
    bool		SetSplitterPercent( UINT percent, bool bUpdate = true );
    
protected:
    void		GetSplitterBarRect( QRect& rc ) const ;
    bool		IsProportional()
    {
        return true;
    }
    void		UpdatePosFromPercent();
    void		UpdatePercentFromPos();
    void		UpdateLayout( bool redraw = false );
    
    
    
    
    // Generated message map functions
    
    
    virtual bool    OnPaint( QGraphics* );//{return true;}
    //virtual bool    OnNcPaint(QWindowGraphics&  ){return false;}
    
    virtual bool    OnEraseBackground( QGraphics* );//{ return true;}
    virtual bool    OnSize( int type, int cx, int cy );
    
    virtual bool    OnPreRegisterClass( WNDCLASS& wcex );
    virtual bool    OnPreCreate( CREATESTRUCT& cs );
    virtual bool	OnLButtonDown( UINT nFlags, QPoint& point );
    virtual bool	OnLButtonUp( UINT nFlags, QPoint& point );
    virtual bool	OnLButtonDblClk( UINT nFlags, QPoint& point );
    virtual bool	OnMouseMove( UINT nFlags, QPoint& point );
    virtual bool	OnContextMenu( HWND h, QPoint& point );
    virtual bool	OnMouseActivate( HWND hwnd, UINT nHitTest, UINT message, LRESULT& lResult )
    {
        lResult = MA_NOACTIVATE;    //sa nu fure focusul
        return true;
    }
};

}

}//micro